<template>
  <div class="side-item" @click="jump">
    <div class="pic">
      <img :src="side_url" alt="" />
    </div>
    <div class="desc">
      <div class="title">{{ title }}</div>
      <div class="address-box">
        <span class="icon">
          <img src="@/assets/goImages/U4.png" alt="" />
        </span>
        <span class="address">{{ address }}</span>
      </div>
      <div class="author-info">
        <div class="author">
          <span class="head">
            <img :src="head_url" alt="" />
          </span>
          <span class="nick">{{ nickName }}</span>
        </div>
        <div class="like" @click.stop="addLike">
          <span class="icon" v-if="like">
            <img src="@/assets/goImages/2f.png" alt="" />
          </span>
          <span class="icon" v-else>
            <img src="@/assets/goImages/3u.png" alt="" />
          </span>

          <span class="like-count">{{ like_count }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    side_url: String,
    title: String,
    address: String,
    head_url: String,
    nickName: String,
    type: Number,
    id: Number,
    count: { type: Number, default: 0 }
  },
  data() {
    return {
      like: false,
      like_count: this.count
    }
  },
  methods: {
    addLike() {
      this.like = !this.like
      if (this.like) {
        this.like_count++
      } else {
        this.like_count--
      }
    },
    jump() {
      if (this.type == 5) {
        this.$router.push('/video/' + this.id)
      } else {
        this.$router.push('/dynamic/' + this.id)
      }
    }
  }
}
</script>

<style lang="less" scoped>
.side-item {
  margin-bottom: 15px;
  .pic {
    width: 100%;
    border-radius: 10px;
    overflow: hidden;

    img {
      width: 100%;
      height: auto;
    }
  }

  .desc {
    .title {
      font-size: 16px;
      color: #333;
      font-weight: 700;
      width: 100%;
      line-height: 24px;
      overflow: hidden;
      text-overflow: ellipsis;
      -webkit-line-clamp: 2;
      display: -webkit-box;
      -webkit-box-orient: vertical;
    }
    .address-box {
      display: flex;
      align-items: center;

      .icon {
        height: 14px;
        width: 14px;

        img {
          height: 100%;
          width: 100%;
        }
      }
      .address {
        color: #999;
        font-size: 12px;
        line-height: 24px;
        margin-left: 5px;
      }
    }
    .author-info {
      display: flex;
      align-items: center;
      justify-content: space-between;

      .author {
        display: flex;
        align-items: center;

        .head {
          height: 30px;
          width: 30px;

          img {
            height: 100%;
            width: 100%;
          }
        }
        .nick {
          font-size: 12px;
          max-width: 60px;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
          color: #323232;
          margin-left: 5px;
        }
      }

      .like {
        display: flex;
        align-items: center;
        .icon {
          height: 14px;
          width: 14px;

          img {
            height: 100%;
            width: 100%;
          }
        }
        .like-count {
          color: #aaa;
          font-size: 12px;
          margin-left: 5px;
        }
      }
    }
  }
}
</style>
